package com.cwf.auth.controller;

import com.cwf.auth.dto.LoginDTO;
import com.cwf.auth.service.ILoginService;
import com.cwf.auth.vo.LoginVO;
import com.cwf.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @PostMapping
    public AjaxResult login(@RequestBody LoginDTO loginDTO){
        try {
            LoginVO result = loginService.login(loginDTO);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("登陆失败！~"+e.getMessage());
        }
    }
    @PutMapping
    public AjaxResult logout(){
        try {
//            LoginVO result = loginService.login();
            return AjaxResult.success();
        } catch (Exception e) {
            return AjaxResult.error("登陆失败！~"+e.getMessage());
        }
    }
}
